package cc.controller;

import cc.eguid.commandManager.RstpToRtmpUtil;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Ffch4jController {
    @RequestMapping("")
    public String helloworld(){
        return "hello world~";
    }

    /**
     * 获取推流地址
     * @param id
     * @param cameraid
     * @return
     */
    @GetMapping("/getRtmpPath")
    public String getRtmpPath(@RequestParam String id , @RequestParam String cameraid){
        if (StringUtils.isEmpty(id) || StringUtils.isEmpty(cameraid)) {
            return null;
        }
        return RstpToRtmpUtil.getRtmpPath(id ,cameraid);
    }

    /**
     * 结束推流
     * @param id
     * @return
     */
    @GetMapping("/stop")
    public boolean stop(@RequestParam String id){
        return RstpToRtmpUtil.stop(id);
    }

    /**
     * 结束所有推流
     * @return
     */
    @GetMapping("/stopAll")
    public boolean stopAll(){
        return RstpToRtmpUtil.stopAll();
    }

    /**
     * 销毁推流服务
     * @return
     */
    @GetMapping("/destory")
    public boolean destory(){
        return RstpToRtmpUtil.destory();
    }
}
